<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="t_sale" :rules="rules" label-width="100px" id="mvcfm">
          <el-button @click="gotoPage('/crm/sale/ModifyAfterSale?'+vueparams+'')" type='success' size="mini"><i class='fa fa-edit'></i>修改</el-button>
          <el-button @click="gotoPage('/crm/sale/ServiceManage?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 记录详情 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="24">
                <el-form-item label="售后标题" prop="">
                  {{t_sale.sale_title}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="产品名称" prop="">
                  {{t_sale.product_id}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="售后状态" prop="">
                  {{getValueName("待处理=0,已处理=1,已确认=2",t_sale.sale_state)}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="产品问题" prop="">
                  {{t_sale.sale_problem}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="备注" prop="">
                  {{t_sale.remark}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="最后一次维修时间" prop="">
                  {{getDateTimeString(t_sale,'sale_update')}}
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-button @click="popIncreaseMaintenRecord('')" type='success' size="mini"><i class='fa fa-plus'></i>增加维修记录</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 维修记录 </span>
          </div>
          <el-table :data="s_record">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_record('&CMIDrecord_id='+scope.row.record_id+'')">删除</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="维修标题" prop="maintain_title">
            </el-table-column>
            <el-table-column label="维修时间" prop="maintain_time">
              <template slot-scope="scope">
                {{getDateTimeString(scope.row,'maintain_time')}}
              </template>
            </el-table-column>
            <el-table-column label="维修人" prop="maintain_person">
            </el-table-column>
            <el-table-column label="维修人电话" prop="maintain_tel">
            </el-table-column>
            <el-table-column label="维修说明" prop="maintain_explain">
            </el-table-column>
          </el-table>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'售后管理'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
    <el-dialog :visible.sync="IncreaseMaintenRecordVisible" append-to-body>
      <IncreaseMaintenRecord v-if="IncreaseMaintenRecordVisible" ref="IncreaseMaintenRecord" :popparams="popparams"> </IncreaseMaintenRecord>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import IncreaseMaintenRecord from "@/views/crm/sale/IncreaseMaintenRecord";
  export default {
    name: 'SaleDetails',
    components: {
      IncreaseMaintenRecord,
    },
    props: ['popparams'],
    data() {
      return {
        IncreaseMaintenRecordVisible: false,
        IncreaseMaintenRecordValue: null,
        IncreaseMaintenRecordDesc: null,
        vueparams: this.getVUEParams(""),
        t_sale: {
          sale_title: null,
          product_id: null,
          sale_state: null,
          sale_problem: null,
          remark: null,
          sale_update: null,
        },
        s_record: [],
        loading: false,
        Container: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "80299289AF2443B18EA545A4C0C37170",
        name: "客户管理右菜单",
        selected: "售后管理"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/crm/sale/AfterSaleAction/saleDetails?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_record(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/AfterSaleAction/d_record?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popIncreaseMaintenRecord(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.IncreaseMaintenRecordVisible = !this.IncreaseMaintenRecordVisible;
      },
    },
  }
</script>
